//
//  MainTabBarController.swift
//  myweibo
//
//  Created by myd on 15/12/15.
//  Copyright © 2015年 myd1. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {
   
    override func viewDidLoad() {
        super.viewDidLoad()
    let home = Home()
        addchildviewcontroller(home, title: "首页" , image:"tabbar_home")
        let dis = Discovery()
        addchildviewcontroller(dis, title: "发现" , image:"tabbar_discover")
        let message = Message()
        addchildviewcontroller(message, title: "消息" , image:"tabbar_message_center")
        let pro = Profol()
        addchildviewcontroller(pro, title: "我" , image:"tabbar_profile")
        let bar = Tabbar()
        bar.dele=self
        self .setValue(bar, forKey: "tabBar")
    }
   
    func addchildviewcontroller(controller : UIViewController ,title : String, image : String)
    {
    
       self.addChildViewController(UINavigationController(rootViewController: controller))
        controller.title=title
        controller.tabBarItem.image=UIImage(named: image)
        controller.tabBarItem.selectedImage=UIImage(named: image+"_highlighted")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor(red: 123/255.0, green: 123/255.0, blue: 123/255.0, alpha: 1)], forState: UIControlState.Normal)
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)

    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

//管理代理方法
extension MainTabBarController : chilkadd1
{
    func chilkadd(chilk: Tabbar) {
        
        presentViewController(mainNavigationController(rootViewController: Extension()), animated: true, completion: nil)
    }
}